<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="/stylesheets/bootstrap.min.css">
    <link rel="stylesheet" href="/stylesheets/newcontrol.css">
    <link rel="shortcut icon" href="/images/maria_favicon.ico" type="image/x-icon" />

    <title>发表新闻</title>
  </head>
<body>

  <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
    <a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3" href="/users/newcontrol">
      <img src="/images/maria.jpg" width="35" height="35" />
      新闻管理
    </a>
    <button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-toggle="collapse" data-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <li class="text-success">状态：已登录&nbsp;&nbsp;用户名：<%= name %>&nbsp;&nbsp;ID：<%= id %></li>
    <ul class="navbar-nav px-3">
      <li class="nav-item text-nowrap">
        <a class="nav-link" href="/users/loginout">登出</a>
      </li>
    </ul>
  </nav>
  
  <div class="container-fluid">
    <div class="row">
      <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
        <div class="sidebar-sticky pt-3">
          <ul class="nav flex-column">
            <li class="nav-item">
              <a class="nav-link" href="/users/newcontrol">
                <span data-feather="newlist">
                    <svg class="feather" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-text" viewBox="0 0 16 16">
                        <path d="M4 0h5.5v1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h1V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z"/>
                        <path d="M9.5 3V0L14 4.5h-3A1.5 1.5 0 0 1 9.5 3z"/>
                        <path fill-rule="evenodd" d="M5 11.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm0-2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/>
                    </svg>
                </span>
                新闻列表 
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link active" href="/users/newcontrol/writenew">
                <span data-feather="writenew">
                    <svg class="feather" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-plus" viewBox="0 0 16 16">
                        <path d="M4 0h5.5v1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h1V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z"/>
                        <path d="M9.5 3V0L14 4.5h-3A1.5 1.5 0 0 1 9.5 3z"/>
                        <path fill-rule="evenodd" d="M8 6.5a.5.5 0 0 1 .5.5v1.5H10a.5.5 0 0 1 0 1H8.5V11a.5.5 0 0 1-1 0V9.5H6a.5.5 0 0 1 0-1h1.5V7a.5.5 0 0 1 .5-.5z"/>
                    </svg>
                </span>
                发表新闻
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/users/newcontrol/updatenew">
                <span data-feather="updatenew">
                  <svg class="feather" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file-earmark-diff" viewBox="0 0 16 16">
                    <path d="M4 0h5.5v1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5h1V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z"/>
                    <path d="M9.5 3V0L14 4.5h-3A1.5 1.5 0 0 1 9.5 3z"/>
                    <path fill-rule="evenodd" d="M5.5 11.5A.5.5 0 0 1 6 11h4a.5.5 0 0 1 0 1H6a.5.5 0 0 1-.5-.5zM8 5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4A.5.5 0 0 1 8 5z"/>
                    <path fill-rule="evenodd" d="M5.5 7.5A.5.5 0 0 1 6 7h4a.5.5 0 0 1 0 1H6a.5.5 0 0 1-.5-.5z"/>
                  </svg>
                </span>
                修改新闻
              </a>
            </li>
            <br>
            <li class="nav-item">
              <a class="nav-link" href="/users">
                <span data-feather="users">
                  <svg class="feather" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-people-fill" viewBox="0 0 16 16">
                    <path fill-rule="evenodd" d="M7 14s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1H7zm4-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm-5.784 6A2.238 2.238 0 0 1 5 13c0-1.355.68-2.75 1.936-3.72A6.325 6.325 0 0 0 5 9c-4 0-5 3-5 4s1 1 1 1h4.216zM4.5 8a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5z"/>
                  </svg>
                </span>
                系统主页
              </a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="/">
                <span data-feather="new">
                  <svg class="feather" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-house" viewBox="0 0 16 16">
                    <path fill-rule="evenodd" d="M2 13.5V7h1v6.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V7h1v6.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 13.5zm11-11V6l-2-2V2.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5z"/>
                    <path fill-rule="evenodd" d="M7.293 1.5a1 1 0 0 1 1.414 0l6.647 6.646a.5.5 0 0 1-.708.708L8 2.207 1.354 8.854a.5.5 0 1 1-.708-.708L7.293 1.5z"/>
                  </svg>
                </span>
                新闻首页
              </a>
            </li>
          </ul>
    </nav>

    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
        <h2>发表新闻</h2>
        <% if(msg){ %>
          <div class="alert alert-secondary" role="alert" style="position: absolute;left: 45%;top: 20%;">
            <strong><%= msg %></strong>
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
              <span aria-hidden="true">&times;</span>
            </button>
         </div>
        <% } %>
        <form class="was-validated" action="/users/newcontrol/publishnew" method="POST">
          <div class="form-group">
            <label for="formGroupExampleInput">作者</label>
            <input type="text" class="form-control" id="author" name="author" placeholder="请输入作者姓名" required>
            <div class="invalid-feedback">您还没有输入作者姓名</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput2">身份</label>
            <input type="text" class="form-control" id="author_brief" name="author_brief" placeholder="请输入作者身份" required>
            <div class="invalid-feedback">您还没有输入作者身份</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput3">类别</label>
            <select class="custom-select" required id="category_id" name="category_id">
              <option value="">请选择新闻类别...</option>
              <option value="1">时政</option>
              <option value="2">军事</option>
              <option value="3">财经</option>
              <option value="4">娱乐</option>
              <option value="5">文化</option>
              <option value="6">游戏</option>
            </select>
            <div class="invalid-feedback">您还没有选择新闻类别</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput4">标题</label>
            <input type="text" class="form-control" id="title" name="title" placeholder="请输入新闻标题" required>
            <div class="invalid-feedback">您还没有输入新闻标题</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput5">简介</label>
            <input type="text" class="form-control" id="cardtext" name="cardtext" placeholder="请输入新闻简介" required>
            <div class="invalid-feedback">您还没有输入新闻简介</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput6">时间</label>
            <input type="datetime-local" class="form-control" id="update_time" name="update_time" required>
            <div class="invalid-feedback">您还没有选择新闻更新时间</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput7">头图</label>
            <input type="text" class="form-control" id="cover" name="cover" placeholder="请输入新闻头图url" required>
            <div class="invalid-feedback">您还没有输入新闻头图url</div>
          </div>
          <div class="form-group">
            <label for="formGroupExampleInput8">新闻内容</label>
            <textarea id="textvalue" name="textvalue" class="form-control" required></textarea>
            <div class="invalid-feedback">您还没有输入新闻内容</div>
            <div id="div1">

            </div>
          </div>
          <button type="submit" class="btn btn-info">提交</button>
        </form>
    </main>
</div>
</div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>

    <script type="text/javascript" src="//unpkg.com/wangeditor/dist/wangEditor.min.js"></script>
    <script type="text/javascript">
    const E = window.wangEditor
    const editor = new E('#div1')
    const $textvalue = $('#textvalue')
    editor.config.onchange = function (html) {
        $textvalue.val(html)
    }
    editor.create();
    $textvalue.val(editor.txt.html())
    </script>

</body>
</html>